﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KBManagement.DAL;
namespace KBManagement.BIZ
{
    class ProductFacade:FacadeBase<Product>
    {
        public override IQueryable Select()
        {
            var products = from fc in Library.Utils.CreateInstance().GetDBContext().Products select fc;
            return products;
        }

        public override Product[] SelectEntities()
        {
            var products = from fc in Library.Utils.CreateInstance().GetDBContext().Products select fc;
            return products.ToArray();
        }

        public override Product Find(object id)
        {
            return SelectEntities().First<Product>(x => (object)x.ID == id);
        }
        public  Product FindByName(string name)
        {
            return SelectEntities().First<Product>(x => x.Name == name);
        }
        public override Product[] FindMany(object id)
        {
            var products = from fc in Library.Utils.CreateInstance().GetDBContext().Products where (object)fc.CategoryID == id select fc;
            return products.ToArray();
        }
    }
}
